﻿#ifndef EDITIMAGEWIDGET_H
#define EDITIMAGEWIDGET_H

#include <QDialog>

class ImageEditer;
class ControlWidget;
class PenSetting;

class EditImageWidget : public QDialog
{
    Q_OBJECT
public:
    explicit EditImageWidget(QImage origImg,QWidget *parent = nullptr);
    ~EditImageWidget();

    void moveToScreenCenter();

    void doForward();
    void Exit(int code);

    void savePixmap();
    void complete();
    void moveControls();

    void initConnectors();

    Q_INVOKABLE void cancel();

signals:
    void finished(int code);
    void forward(QPixmap img);

public slots:
    void on_cliped(QRect);

protected:
    void resizeEvent(QResizeEvent* event) override;
    void closeEvent(QCloseEvent* event) override;
    void moveEvent(QMoveEvent *event) override;
    void hideEvent(QHideEvent *event) override;
    void showEvent(QShowEvent *event) override;
    bool eventFilter(QObject *obj, QEvent *event) override;

private:
    ImageEditer* m_imageEditer = nullptr;
    ControlWidget *m_control = nullptr;
    PenSetting *m_pensetting = nullptr;
    QImage m_origImg;
    QPoint m_startPoint;
    bool m_isPress = false;

    int ratio = 1;
};

#endif // EDITIMAGEWIDGET_H
